package cn.ithers.blog.dao;

import cn.ithers.blog.pojo.ArticleNoAll;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author: zhanghuan
 * @date: 2020/10/6 8:30
 * @description:
 */
public interface ArticleNoAllDao extends JpaRepository<ArticleNoAll, String>, JpaSpecificationExecutor<ArticleNoAll> {
    ArticleNoAll findOneById(String id);

    @Query(nativeQuery = true, value = "select *from tb_article where labels like ? and id != ? limit ?")
    List<ArticleNoAll> listArticleByLikeLabel(String label, String originalArticleId, int size);

    @Query(nativeQuery = true, value = "select *from tb_article where id != ? order by create_time desc limit ?")
    List<ArticleNoAll> listLasteArticleBySize(String originalArticleId, int size);
}
